<template>
   <h1>通过搜索 获取数组中的数据</h1>
    <span>搜索：</span> <input type="text" v-model="search">
    <ul>
        <li v-for="item in arrInput()">
            {{ item }}
        </li>
    </ul>

</template>

<script setup>
import { ref } from 'vue'
const search = ref('')
const arr = ref(["aaa", "bbb", "ccc", "aba", "abb", "bad", "bbc", "bdb", "ccr"])

const arrInput = () => { 

    console.log(arr.value.filter(item => {
        return item.includes(search.value)
    }));
    // 根据输入的数据 过滤数组中包含的值
    let arrinfo = arr.value.filter(item => {
        // 判断数组中是否包含输入的值
        return item.includes(search.value)
    })
    return arrinfo
    
}



</script>

<style lang="scss" scoped>

</style>